#include<iostream>
#include<vector>
#include<queue>
#include<unordered_map>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=14;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn][maxn];
LL rsum[maxn],csum[maxn];
bool vis[11][11];
int main(void)
{
  int n;scanf("%d",&n);
  int m=n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
        a[i][j]=read();
    }
  }
  LL ans=0;
  for(int i1=1;i1<=n;i1++){
      for(int j1=1;j1<=m;j1++){
        for(int i2=1;i2<=n;i2++){
            for(int j2=1;j2<=m;j2++){
                for(int i3=1;i3<=n;i3++){
                    for(int j3=1;j3<=m;j3++){
                        LL res=0;

                        memset(vis,0,sizeof(vis));

                        for(int dj=-2;dj<=2;dj++){
                            int nowi1=i1;
                            int nowj1=j1+dj;

                            if(nowi1<1||nowi1>n||nowj1<1||nowj1>m) continue;
                            if(!vis[nowi1][nowj1]){
                                vis[nowi1][nowj1]=1;
                                res+=a[nowi1][nowj1];
                            }
                        }
                        for(int dj=-2;dj<=2;dj++){

                            int nowi2=i2;
                            int nowj2=j2+dj;
                            if(nowi2<1||nowi2>n||nowj2<1||nowj2>m) continue;
                            if(!vis[nowi2][nowj2]){
                                vis[nowi2][nowj2]=1;
                                res+=a[nowi2][nowj2];
                            }
                        }

                        for(int dj=-2;dj<=2;dj++){
                            int nowi3=i3;
                            int nowj3=j3+dj;
                            if(nowi3<1||nowi3>n||nowj3<1||nowj3>m) continue;
                            if(!vis[nowi3][nowj3]){
                                vis[nowi3][nowj3]=1;
                                res+=a[nowi3][nowj3];
                            }

                        }

                        for(int di=-2;di<=2;di++){
                            int nowi1=i1+di;
                            int nowj1=j1;
                            if(nowi1<1||nowi1>n||nowj1<1||nowj1>m) continue;
                            if(!vis[nowi1][nowj1]){
                                vis[nowi1][nowj1]=1;
                                res+=a[nowi1][nowj1];
                            }
                        }
                        for(int di=-2;di<=2;di++){

                            int nowi2=i2+di;
                            int nowj2=j2;
                            if(nowi2<1||nowi2>n||nowj2<1||nowj2>m) continue;
                            if(!vis[nowi2][nowj2]){
                                vis[nowi2][nowj2]=1;
                                res+=a[nowi2][nowj2];
                            }
                        }
                        for(int di=-2;di<=2;di++){

                            int nowi3=i3+di;
                            int nowj3=j3;

                            if(nowi3<1||nowi3>n||nowj3<1||nowj3>m) continue;
                            if(!vis[nowi3][nowj3]){
                                vis[nowi3][nowj3]=1;
                                res+=a[nowi3][nowj3];
                            }

                        }
                        ans=max(ans,res);
                    }

                }
            }
        }
    }
  }
  printf("%lld\n",ans);
return 0;
}
